package com.chixing.day15.INPUT_OUTPUT;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;

public class OutputStreamDemo {
    public static void main(String[] args){
        //"f://workspacetools//CXJY_WORKSPACE//test1//hello.txt")
        /*
         1.创建字节写入流
         2.谢数据
         3.关闭流
         */

        //1
        OutputStream os = null;
        try {
              os = new FileOutputStream("f://workspacetools//CXJY_WORKSPACE//test1//hello.txt");
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }

        //2
        String content = "Hello This is Jason Marslyon speaking";
        try {
            os.write(content.getBytes());
        } catch (IOException e) {
           e.printStackTrace();
        }finally{//3 :释放内存,节约资源
            if(os != null){
                try {
                    os.close();
                } catch (IOException e) {
                   e.printStackTrace();
                }
            }
        }



    }
}
